import time

from hytest import STEP,INFO,CHECK_POINT,GSTORE
from pom.basepage.basepage import driver_get,BasePage
from pom.page_teacher_op.homepage import THomePage
from pom.page_teacher_op.homework_create_page import THomeworkCreatePage, IFrameGreateHomework
from pom.page_teacher_op.homework_created_page import THomeworkCreatedPage
from pom.page_teacher_op.login_page import TLoginPage
from pom.page_teacher_op.question_info_page import QuestionInfoPage
from pom.page_teacher_op.release_to_student_page import TReleaseToStudent
from pom.page_teacher_op.released_page import TRelease
from lib.share import *

def suite_setup():
    driver = driver_get('Chrome')
    GSTORE['driver'] = driver

    GSTORE['tlogin'] = TLoginPage(driver)

    GSTORE['thome'] = THomePage(driver)
    GSTORE['thomework_create'] = THomeworkCreatePage(driver)
    GSTORE['iframe_homework_create'] = IFrameGreateHomework(driver)
    GSTORE['thomework_created'] = THomeworkCreatedPage(driver)
    GSTORE['question_info'] = QuestionInfoPage(driver)
    GSTORE['release_to_student'] = TReleaseToStudent(driver)
    GSTORE['release'] = TRelease(driver)

    GSTORE['tlogin'].open(GSTORE['tlogin'].t_url)
    GSTORE['tlogin'].login()

    GSTORE['teardown_button_list'] = []
    GSTORE['teardown_floor_dict'] = []

def suite_teardown():
    # GSTORE['thome'].open_homework_released()
    # r_index = 1
    # GSTORE['thome'].driver.implicitly_wait(1)
    # while True:
    #     try:
    #         GSTORE['release'].click_floor(xpath,GSTORE['release'].loc_delete_value,index1=1)
    #         GSTORE['release'].click(GSTORE['release'].loc_delete_submit)
    #         try:
    #             GSTORE['release'].click(GSTORE['release'].loc_delect_lose)
    #             r_index += 1
    #             if r_index == 11:
    #                 r_index = 1
    #                 GSTORE['release'].click(GSTORE['release'].loc_next_page)
    #         except:
    #             pass
    #     except:
    #         break
    # GSTORE['thome'].driver.implicitly_wait(5)

    GSTORE['driver'].quit()

